package _1_String;

public class A05_replaceSpace {
    //用StringBuffer
    public String replaceSpace(String s) {
        int i = 0;
        StringBuilder stringBuilder = new StringBuilder(s);

        while(i < stringBuilder.length()){
            if (stringBuilder.charAt(i) == ' '){
                stringBuilder.replace(i,i+1,"%20");
            }
            i++;
        }
        String s1 = stringBuilder.toString();

        return s1;
    }
}
